<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .red {
            color: red;
        }
        
        .gray {
            background: #ccc;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1 @click="change">{{msg}}</h1>
        <button v-on:click="handler('dianji')">点击</button>
        <!-- 绑定事件，简写为@ -->
        <input type="text" v-model="msg" />

        <h5 class="red gray">{{msg}}</h5>
        <h5 v-bind:class="{red:flag,gray:flag}">{{msg}}</h5>
        <h5 :class="{red:flag,gray:flag}">{{msg}}</h5>
        <!-- v-bind可以简写为: -->
    </div>

    <script src="vue-2.4.0.js"></script>
    <script>
        let vm = new Vue({
            el: "#app", //代表vue作用的范围
            data: {
                msg: "这是一个vue实例",
                flag: true,
            },
            methods: {
                change() {
                    alert("这是vue里的方法methods");
                },
                handler(val) {
                    alert(val);
                },
            },
        });
    </script>
</body>

</html>